#pragma once

#include "Hash.h"

namespace byh
{
	template<class K, class HashIFunc = hash_bucket::Integer<K>>
	class unordered_set
	{
	public:
		struct KeyOfSet
		{
			const K& operator()(const K& t) 
			{
				return t;
			}
		};

		typedef typename hash_bucket::HashTable<K, const K, KeyOfSet, HashIFunc>::Iterator iterator;
		typedef typename hash_bucket::HashTable<K, const K, KeyOfSet, HashIFunc>::const_Iterator const_iterator;

		pair<iterator, bool> insert(const K& key)
		{
			return _ht.insert(key);
		}

		iterator begin()
		{
			return _ht.begin();
		}

		iterator end()
		{
			return _ht.end();
		}

		const_iterator begin() const
		{
			return _ht.begin();
		}

		const_iterator end() const
		{
			return _ht.end();
		}

	protected:
		hash_bucket::HashTable<K, const K, KeyOfSet, HashIFunc> _ht;
	};

	void Test_unordered_set()
	{
		unordered_set<int> hash;
		hash.insert(3);
		hash.insert(2);
		hash.insert(1);
		hash.insert(4);
		hash.insert(7);
		hash.insert(8);
		hash.insert(10);
		hash.insert(2);
		hash.insert(1);
		hash.insert(5);

		unordered_set<int>::iterator it = hash.begin();
		while (it != hash.end())
		{
			cout << *it << " ";
			++it;
		}
		cout << endl;
	}
}